/* 
 * File:   Descriptor.cpp
 * Author: max
 * 
 * Created on October 13, 2012, 9:15 AM
 */

#include "DescriptorReader.h"
using namespace TP;

DescriptorReader::DescriptorReader(){
    this->descriptor = "";
}

DescriptorReader::~DescriptorReader(){}

string& DescriptorReader::Descripor(){
    return this->descriptor;
}

namespace TP{

    istream& operator>> (istream& stream, DescriptorReader& reader){

        reader.descriptor = "";
        char caracter;

        while (!stream.eof())
        {
            caracter = stream.peek();

            if ((caracter >= '0' && caracter <= '9')|| caracter == ','|| caracter == ':')
            {
                stream.get(caracter);
                reader.descriptor += caracter;
            }
            else if (caracter == 'R' || 
                     caracter == 'P' ||  
                     caracter == 'C' ||  
                     caracter == 'V' ||  
                     caracter == 'L') 
            {
                size_t found = reader.descriptor.find(':', 0);
                if ( string::npos == found  )
                {
                    stream.get(caracter);
                    reader.descriptor += caracter;
                }
                else
                    break;
            }
            else
                stream.get(caracter);
        }
        return stream;
    }
}




